<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box{
        position: relative;
        width: 250px;
        height: 250px;
        /* border: 1px solid red; */
        margin: 150px auto;

        transform-style: preserve-3d;
        transform: rotateX(40deg) rotateY(-31deg);
        transition: transform 2s;
    }
    .box:hover{
        transform: rotateX(360deg) rotateY(360deg);
    }
    .box > div{
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
    }
    .left{
        background: red;
        transform: translateX(-125px) rotateY(90deg);
    }
    .right{
        background: greenyellow;
        transform: translateX(125px) rotateY(90deg);
    }
    .forward{
        background: yellow;
        transform: translateZ(125px);
    }
    .back{
        background-color: hotpink;
        transform: translateZ(-125px);
    }
    .up{
        background-color: blue;
        transform: translateY(-125px) rotateX(90deg);
    }
    .down{
        background-color: blueviolet;
        transform: translateY(125px) rotateX(90deg);
    }
</style>
<body>
    <div class="box">
        <div class="up">上</div>
        <div class="down">下</div>
        <div class="left">左</div>
        <div class="right">右</div>
        <div class="forward">前</div>
        <div class="back">后</div>
    </div>
</body>
</html>